package com.yili.oa.dao;

import com.yili.oa.models.User;
import com.yili.oa.models.UserExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface UserMapper {
    @SelectProvider(type=UserSqlProvider.class, method="countByExample")
    long countByExample(UserExample example);

    @DeleteProvider(type=UserSqlProvider.class, method="deleteByExample")
    int deleteByExample(UserExample example);

    @Delete({
        "delete from user",
        "where user_id = #{userId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String userId);

    @Insert({
        "insert into user (user_id, user_account, ",
        "user_password, user_name, ",
        "user_sex, user_apartment, ",
        "user_create_time, user_create_user, ",
        "user_update_time, user_update_user, ",
        "user_mobile_phone, user_sort, ",
        "user_status, user_role)",
        "values (#{userId,jdbcType=VARCHAR}, #{userAccount,jdbcType=VARCHAR}, ",
        "#{userPassword,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, ",
        "#{userSex,jdbcType=VARCHAR}, #{userApartment,jdbcType=VARCHAR}, ",
        "#{userCreateTime,jdbcType=TIMESTAMP}, #{userCreateUser,jdbcType=VARCHAR}, ",
        "#{userUpdateTime,jdbcType=TIMESTAMP}, #{userUpdateUser,jdbcType=VARCHAR}, ",
        "#{userMobilePhone,jdbcType=VARCHAR}, #{userSort,jdbcType=VARCHAR}, ",
        "#{userStatus,jdbcType=VARCHAR}, #{userRole,jdbcType=VARCHAR})"
    })
    int insert(User record);

    @InsertProvider(type=UserSqlProvider.class, method="insertSelective")
    int insertSelective(User record);

    @SelectProvider(type=UserSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="user_account", property="userAccount", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_password", property="userPassword", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_name", property="userName", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_sex", property="userSex", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_apartment", property="userApartment", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_create_time", property="userCreateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="user_create_user", property="userCreateUser", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_update_time", property="userUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="user_update_user", property="userUpdateUser", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_mobile_phone", property="userMobilePhone", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_sort", property="userSort", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_status", property="userStatus", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_role", property="userRole", jdbcType=JdbcType.VARCHAR)
    })
    List<User> selectByExample(UserExample example);

    @Select({
        "select",
        "user_id, user_account, user_password, user_name, user_sex, user_apartment, user_create_time, ",
        "user_create_user, user_update_time, user_update_user, user_mobile_phone, user_sort, ",
        "user_status, user_role",
        "from user",
        "where user_id = #{userId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="user_account", property="userAccount", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_password", property="userPassword", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_name", property="userName", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_sex", property="userSex", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_apartment", property="userApartment", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_create_time", property="userCreateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="user_create_user", property="userCreateUser", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_update_time", property="userUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="user_update_user", property="userUpdateUser", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_mobile_phone", property="userMobilePhone", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_sort", property="userSort", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_status", property="userStatus", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_role", property="userRole", jdbcType=JdbcType.VARCHAR)
    })
    User selectByPrimaryKey(String userId);

    @UpdateProvider(type=UserSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);

    @UpdateProvider(type=UserSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") User record, @Param("example") UserExample example);

    @UpdateProvider(type=UserSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(User record);

    @Update({
        "update user",
        "set user_account = #{userAccount,jdbcType=VARCHAR},",
          "user_password = #{userPassword,jdbcType=VARCHAR},",
          "user_name = #{userName,jdbcType=VARCHAR},",
          "user_sex = #{userSex,jdbcType=VARCHAR},",
          "user_apartment = #{userApartment,jdbcType=VARCHAR},",
          "user_create_time = #{userCreateTime,jdbcType=TIMESTAMP},",
          "user_create_user = #{userCreateUser,jdbcType=VARCHAR},",
          "user_update_time = #{userUpdateTime,jdbcType=TIMESTAMP},",
          "user_update_user = #{userUpdateUser,jdbcType=VARCHAR},",
          "user_mobile_phone = #{userMobilePhone,jdbcType=VARCHAR},",
          "user_sort = #{userSort,jdbcType=VARCHAR},",
          "user_status = #{userStatus,jdbcType=VARCHAR},",
          "user_role = #{userRole,jdbcType=VARCHAR}",
        "where user_id = #{userId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(User record);
}